package com.mobilesales.android.actionbar;

import com.jeremyfeinstein.slidingmenu.lib.SlidingMenu;
import com.mobilesales.android.R;
import com.mobilesales.android.adapters.SlidingMenus;
import com.mobilesales.android.util.MessageBox;

import android.app.Activity;
import android.content.Context;
import android.support.v7.app.ActionBar;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageButton;
import android.widget.TextView;
import android.widget.Toast;

public class Main_ActionBar implements OnClickListener {

	Activity activity;
	SlidingMenu sliding = null;

	public Main_ActionBar(Activity activity) {
		this.activity = activity;
		sliding = new SlidingMenus(activity).getSlidingMenu();
	}

	public void getActionBar(ActionBar mActionBar) {

		mActionBar.setDisplayShowHomeEnabled(false);
		mActionBar.setDisplayShowTitleEnabled(false);
		Context ct = activity.getApplicationContext();
		LayoutInflater mInflater = LayoutInflater.from(ct
				.getApplicationContext());

		View mCustomView = mInflater.inflate(R.layout.actionbarcustomize, null);

		TextView mTitleTextView = (TextView) mCustomView
				.findViewById(R.id.actionbarcus_text);

		mTitleTextView.setText(activity.getTitle() + " - Dat Viet");

		ImageButton imageButton = (ImageButton) mCustomView
				.findViewById(R.id.actionbarcus_icon);

		imageButton.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				if (!sliding.isMenuShowing())
					sliding.showMenu();
				sliding.showMenu(false);
				Toast.makeText(v.getContext(), "", Toast.LENGTH_LONG).show();
			}
		});
		mActionBar.setCustomView(mCustomView);
		mActionBar.setDisplayShowCustomEnabled(true);

	}

	public void onClick(View v) {
		// TODO Auto-generated method stub

	}
}
